/**
 * 学习目标：使用setState修改状态
 */
import React from 'react';
import ReactDOM from 'react-dom';

class App extends React.Component {
  state = {
    count: 0,
  };
  render() {
    return (
      <div>
        <h1>{this.state.count}</h1>
        <button onClick={this.change}>点我+1</button>
      </div>
    );
  }
  change = () => {
    console.log('this  ----->  ', this.state.count + 1);
    // 使用setState修改状态
    this.setState({
      count: this.state.count + 1,
    });
  };
}

ReactDOM.render(<App></App>, document.getElementById('root'));
